//
//  CustomKits.m
//  苏州银行
//
//  Created by rimi on 15/8/20.
//  Copyright (c) 2015年 IOS. All rights reserved.
//

#import "CustomKits.h"

@implementation CustomKits


+ (UILabel *)labelWithOrigin:(CGPoint)origin//初始位置
                        Text:(NSString *)text
                    FontSize:(CGFloat)fontSize
               TextAlignment:(NSTextAlignment)textAlignment
                   TextColor:(UIColor *)textColor
             BackGroundColor:(UIColor *)backColor
                CornerRadius:(CGFloat)radius
                 BorderWidth:(CGFloat)width
                 BorderColor:(UIColor *)borderColor
                    MaxWidth:(CGFloat)MaxWidth
                      finalY:(void(^)(CGFloat finalY))finalY//回调label最终Y位置
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.text = text;
    label.font = [UIFont systemFontOfSize:fontSize];
    label.textColor = textColor;
    label.numberOfLines = 0;
    CGRect rect = [text boundingRectWithSize:CGSizeMake(MaxWidth, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:label.font} context:nil];
    label.frame = CGRectMake(origin.x, origin.y, rect.size.width, rect.size.height);
    
    
    label.textAlignment = textAlignment;
    label.backgroundColor = backColor;
    label.layer.cornerRadius = radius;
    label.layer.borderWidth = width;
    label.layer.borderColor = borderColor.CGColor;
    finalY(origin.y+label.bounds.size.height);
    
    return label;
    
}

+ (UILabel *)labelWithFrame:(CGRect)frame
                       Text:(NSString *)text
                   FontSize:(CGFloat)fontSize
              TextAlignment:(NSTextAlignment)textAlignment
                  TextColor:(UIColor *)textColor
            BackGroundColor:(UIColor *)backColor
               CornerRadius:(CGFloat)radius
                BorderWidth:(CGFloat)width
                BorderColor:(UIColor *)borderColor
{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = [UIFont systemFontOfSize:fontSize];
    label.textColor = textColor;
    label.numberOfLines = 0;
    label.textAlignment = textAlignment;
    label.backgroundColor = backColor;
    label.layer.cornerRadius = radius;
    label.layer.borderWidth = width;
    label.layer.borderColor = borderColor.CGColor;
    return label;
}


+ (UIButton *)buttonWithFrame:(CGRect)frame
                        Title:(NSString *)title
               BackGroudImage:(UIImage *)image
              BackGroundColor:(UIColor *)color
                    TextColor:(UIColor *)textColor
                 CornerRadius:(CGFloat)radius
                  BorderWidth:(CGFloat)width
                  BorderColor:(UIColor *)borderColor;
{
    UIButton *button = [UIButton buttonWithType:0];
    button.frame = frame;
    [button setTitle:title forState:0];
    [button setBackgroundImage:image forState:0];
    button.backgroundColor = color;
    [button setTitleColor:textColor forState:0];
    
    button.layer.cornerRadius = radius;
    button.layer.borderWidth = width;
    button.layer.borderColor = borderColor.CGColor;
    return button;
}











@end
